import java.util.ArrayList;
import java.util.List;

public class Leet22 {
    static List<String> list = new ArrayList<>();
    public static void main(String[] args) {
        int l = 1,r = 1;
        dfs(l,r,"");
        for (String s : list) {
            System.out.println(s);
        }
    }
    static void dfs(int l,int r,String sb){
        if (l==0&&r==0){
            list.add(sb);
            return;
        }
        if (l==r&&l>0){
            dfs(l-1,r,sb+"(");
        }else if (l<r){
            if (l!=0){
                dfs(l-1,r,sb+"(");
            }
            if (r != 0) {
                dfs(l,r-1,sb+")");
            }
        }
    }
}
